package com.sky.mapper;


import com.sky.annotation.AutoFill;
import com.sky.entity.ShoppingCart;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    /*
    *
    * 查询购物车
    *
    * */
    List<ShoppingCart> selectByShoppingCart(ShoppingCart shoppingCart);


    /*
    *
    * 添加到购物车
    *
    * */
    void insert(ShoppingCart shoppingCart);


    /*
    *
    * 根据id添加购物车菜品数量（加一）
    *
    * */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumberById(ShoppingCart shoppingCart);


    /*
     *
     * 查看购物车
     *
     * */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> select(Long userId);


    /*
     *
     * 清空购物车
     *
     * */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteAll(Long userId);


    /*
    *
    * 根据购物车id删除对应商品
    *
    * */
    @Delete("delete from shopping_cart where id = #{id}")
    void deleteByid(Long id);
}
